package com.inool.typehandler;

import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.extension.handlers.AbstractJsonTypeHandler;
import com.inool.model.ScheduleInfo;
import org.apache.ibatis.type.JdbcType;
import org.apache.ibatis.type.MappedJdbcTypes;
import org.apache.ibatis.type.MappedTypes;

import java.util.List;

@MappedTypes(List.class)
@MappedJdbcTypes(JdbcType.LONGNVARCHAR)
public class ScheduleInfoListTypeHandler extends AbstractJsonTypeHandler<List<ScheduleInfo>> {
    @Override
    protected List<ScheduleInfo> parse(String json) {
        return JSON.parseArray(json, ScheduleInfo.class);
    }

    @Override
    protected String toJson(List<ScheduleInfo> obj) {
        return JSON.toJSONString(obj);
    }
}